package model;

import com.alibaba.fastjson2.annotation.JSONField;
import lombok.Data;

import java.util.Arrays;

@Data
public class Finance {
    @JSONField(name = "SECUCODE", alternateNames = {"代码"})
    private String sc;
    @JSONField(name = "SECURITY_NAME_ABBR", alternateNames = {"中文名"})
    private String sna;

    public String toString() {
        return Arrays.stream(Finance.class.getDeclaredFields()).map(
                f -> {
                    try {
                        return f.getAnnotation(JSONField.class).alternateNames()[0] + ':' + f.get(this).toString();
                    } catch (Exception e) {
                        return f.getAnnotation(JSONField.class).name() + ":null";
                    }
                }
        ).toList().toString();
    }
}
